<template>
  <view class="button-card" :class="mode == 'relation' ? 'id-card' : ''">
    <view class="btn-item" :class="formData[mode] == item ? 'active-item' : ''" v-for="(item, index) in range" :key="index" @click="changeItem(item, index)">
      <custom-btn>{{item}}</custom-btn>
    </view>
  </view>
</template>

<script setup>
const updateUserInfo = inject("updateUserInfo", () => {});

const props = defineProps({
  range: {
    type: Array,
    default: () => [],
  },
  mode: {
    type: String,
    default: "",
  },
  formData: {
    type: Object,
    default: () => ({}),
  },
});

const changeItem = (v, i) => {
  props.formData[props.mode] = v;
  if (props.mode == "relation") return;
  updateUserInfo("popup");
};
</script>

<style lang=scss scoped>
.button-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  font-weight: bold;
  font-size: 36rpx;
  color: #000;
  padding-top: 60rpx;
}

.btn-item {
  width: 650rpx;
  height: 140rpx;
  line-height: 140rpx;
  background: #f8f8f8;
  border-radius: 60rpx;
  margin: 20rpx auto;
}

.id-card {
  .btn-item {
    width: 48%;
    height: 120rpx;
    line-height: 120rpx;
    text-align: center;
    background: #f8f8f8;
    border-radius: 10rpx;
    margin-bottom: 20rpx;
  }
}

.active-item {
  color: #fff;
  background: linear-gradient(
    180deg,
    rgba(241, 55, 64, 0.9) 0%,
    #f13740 100%
  ) !important;
}
</style>